import axios from 'axios'

// 用户登录 - 确保正确的数据格式
export const login = (loginData) => {
  const data = {
    username: loginData.username,
    password: loginData.password,
    rememberMe: loginData.rememberMe || false
  };
  
  console.log('API调用login, 用户名:', data.username);
  
  return axios.post('/auth/login', data, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 用户注册
export const register = (registerData) => {
  return axios.post('/auth/register', registerData, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 获取用户信息
export const getUserInfo = () => {
  return axios.get('/user/info');
}

// 退出登录
export const logout = () => {
  return axios.post('/auth/logout');
} 
 